<!--
 * @Descripttion: 
 * @version: 1.0
 * @Author: lynn
 * @Date: 2020-10-21 20:01:28
 * @LastEditors: lynn
 * @LastEditTime: 2020-10-22 08:11:50
-->
<template>
    <div>
        <h2 style="width: 95%; margin:10px auto">试题库管理</h2>
        <div style="width: 95%; margin:10px auto">
            <el-button>上传试题</el-button>
        </div>
        
        <el-table
        :data="examSubject"
            style="width: 95%; margin:auto">
                <el-table-column
                    type="index"
                    label="编号"
                    width="60">
                </el-table-column>
                <el-table-column
                    label="科目"
                    width="139">
                </el-table-column>
        <el-table-column  v-for="(item,index) in examType" :key="index" :label="item+'考试数量'">
            <el-table-column
                prop="name"
                label="可用"
                width="65">
            </el-table-column>
            <el-table-column
                prop="name"
                label="禁用"
                width="65">
            </el-table-column>
            <el-table-column
                prop="name"
                label="删除"
                width="65">
            </el-table-column>
        </el-table-column>


        <el-table-column label="操作" width="100">
            
        </el-table-column>
    </el-table>
    {{tableData}}
    </div>
</template>

<script>
import {mapState,mapMutations,mapActions} from "vuex";
    export default {
        data() {
            return {
                examType:["周考一","周考二","周考三","月考"],
                examSubject:["结构样式","javaScript上","javaScript下","模块化开发","移动开发","node","组件化开发","渐进式开发","项目实战","高级node","实训一"]
            }
        },
        computed: {
            ...mapState({
                list:(state)=>state.paper.paperList,
                // arr:(state)=>state.paper.arr
            }),
            tableData:function(){
                // let tableData=[];
                let exam_subjects = [...new Set(this.list.map((item)=>item.exam_subject))].sort(function(a,b){return a-b})
                exam_subjects.forEach((item,index)=>{
                    //过滤出这个科目的所有试题
                    let exams = this.list((value)=>value.exam_subject===item);
                    console.log(exams)
                    return exams;
                    //过滤出周考和月考试题
                    let exam_types = [0,1,2,3].map((item)=>{
                        console.log(item)
                    })
                })
                console.log(1)
                // return exam_subjects
            }
        },
        methods: {
            ...mapActions({
                getPaperList:"paper/getPaperList",
            })
        },
        created() {
            this.getPaperList();
        },
    }
</script>

<style lang="scss" scoped>
    .el-table-column{
        text-align: center !important;
    }
</style>